package org.ghost.wechat.platform.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.ghost.wechat.platform.entity.MediaPlatform;
import org.ghost.wechat.platform.mapper.MediaPlatformMapper;
import org.ghost.wechat.platform.service.IMediaPlatformService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务号配置表 服务实现类
 * </p>
 *
 * @author 01
 * @since 2019-10-17
 */
@Service
public class MediaPlatformServiceImpl extends ServiceImpl<MediaPlatformMapper, MediaPlatform> implements IMediaPlatformService {

    @Override
    public MediaPlatform getOne(String token, String... columns) {
        if (StringUtils.isNotBlank(token)) {
            Wrapper<MediaPlatform> wrapper = new EntityWrapper<MediaPlatform>()
                    .eq("data_state", 1)
                    .eq("app_token", token);
            if (ArrayUtils.isNotEmpty(columns)) {
                wrapper.setSqlSelect(columns);
            }
            this.selectOne(wrapper);
        }
        return null;
    }
}
